import React from 'react';
import {Modal } from 'antd';
import {injectIntl} from 'react-intl';

class SCModal extends React.PureComponent {
    constructor(props) {
        super(props);
        this.state = {
            visible: false,
        };
    }

    componentWillReceiveProps(nextProps) {
        console.log('nextProps')
        this.setState({
            visible: nextProps.visible,
        });
    }


    handleOk = () => {
        this.setState({
            visible: false,
        });
    };


    render() {
        const { visible } = this.state;
        return (
            <div>
                {visible&&<Modal visible={visible}
                       onOk={this.handleOk}
                       destroyOnClose={true}
                       width={800}
                       onCancel={this.props.handleCancel||this.handleOk}
                       footer={[<div key={1} style={{height: 22}}></div>]}
                       {...this.props}
                >
                    {this.props.children}
                </Modal>}
            </div>
        );
    }
}

export default injectIntl(SCModal)